﻿using System;
using Coolite.Ext.Web;
using CooliteExamples.Code.DAL;
using CooliteExamples.Web.Code;

namespace CooliteExamples.Web.Pages.Communication
{
		public partial class StoreExample : PageBase
		{
				protected void Page_Load(object sender, EventArgs e)
				{
						if (!Ext.IsAjaxRequest && !IsPostBack)
						{
								LoadPage();
						}
				}

				private void LoadPage()
				{
						BookStore2.Proxy.Add(new HttpProxy()
																															{
																																	DisableCaching = true,
																																	Json = true,
																																	Method = HttpMethod.GET,
																																	Url = Core.ProcessController.Handlers.Book.GetAllBooksHandlerUrl()
																															});

				}

				protected void btnBookStore1_Click(object sender, AjaxEventArgs ev)
				{
						var list = BookDal.GetBooks();
						BookStore1.DataSource = list;
						BookStore1.DataBind();
				}

				protected void btnBookStore2_Click(object sender, AjaxEventArgs ev)
				{
						BookStore2.DataBind();
				}
		}
}
